package com.byxy.xyqas.controller;

import javax.servlet.http.HttpSession;

import com.byxy.xyqas.service.ReplyService;
import com.byxy.xyqas.vo.ReplyVO;
import com.byxy.xyqas.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class ReplyController {
	@Autowired
	private ReplyService replyService;

	@RequestMapping("publishReply.do")
	public String publishReply(@RequestParam("tip_id") Integer tipId,
			@RequestParam("reply_content") String replyContent, HttpSession session) {
		UserVO userVO = (UserVO) session.getAttribute("USER");
		ReplyVO replyVO = new ReplyVO();
		replyVO.setTipId(tipId);
		replyVO.setReplyContent(replyContent);
		replyVO.setUserId(userVO.getUserId());
		replyVO.setUserName(userVO.getUserName());
		replyVO.setUserNick(userVO.getUserNick());
		replyService.add(replyVO);
		return "redirect:showTip.do?tipId=" + tipId;
	}
}
